package pt.ipleiria.plp.Lixeiras;

/**
 * The result of a send operation
 * @author Filipe Felisberto e Ricardo Silva
 */
public class LixeiraSendResult {

    private boolean sucess;
    private String error;
    private LixeiraSent lix;

    /**
     * Constructor to be used when no error ocurred
     * @param lix the lixeira that was sent
     */
    public LixeiraSendResult(LixeiraSent lix) {

        this.error = null;
        this.sucess = true;
        this.lix = lix;

    }
    /**
     * Constructor to be used when an error ocurred but the lixeira was sent,
     * normally when this happens is due to an image error
     * @param lix the lixeira that was sent
     * @param error the error message
     */
    public LixeiraSendResult(LixeiraSent lix, String error) {

        this.error = error;
        this.sucess = false;
        this.lix = lix;

    }
    /**
     * Constructor to be used when an error ocurred and the lixeira wasn't sent
     * @param error the error message
     */
    public LixeiraSendResult(String error) {
        this.error = error;
        this.sucess = false;

    }

    /**
     * @return the newGuid
     */
    public String getNewGuid() {
        if (getLixeira() != null) {
            return getLixeira().getGuid();
        } else {
            return null;
        }
    }

    public boolean wasSuceded() {
        return sucess;
    }

    /**
     * @return the error
     */
    public String getError() {
        return error;
    }

    /**
     * @return the lix
     */
    public LixeiraSent getLixeira() {
        return lix;
    }
}
